﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Fluq.Tests.Mocks
{
	//NOTE: MarshalByRefObject and IDisposable only needed for testing purposes
	public class ParentFunc : MarshalByRefObject, IDisposable
	{
		private Child _child;
		private Func<Child> _childFactory;

		public ParentFunc(Func<Child> childFactory)
		{
			_childFactory = childFactory;

			_child = _childFactory();
		}

		public Child Child
		{
			get
			{
				if (_child == null)
				{
					_child = _childFactory();
				}

				return _child;
			}
		}

		public void Dispose()
		{

		}
	}
}
